#pragma once

#include<thread>
#include<mutex>
#include <string>
#include <vector>


struct Message
{
	std::string msg;
	bool quit{ false };
};

class BinaryQueue
{
public:
	static const int MAX_MESSAGE_COUNT = 5;

	BinaryQueue();
	virtual ~BinaryQueue();

	void enqueueIdle(Message* msg);
	Message* dequeueIdle();

	void enqueueBusy(Message* msg);
	Message* dequeueBusy();

	int32_t getIdleCount() const 
	{
		return this->idleCount;
	}

	int32_t getBusyCount() const
	{
		return this->busyCount;
	}


private:

	Message* allMsg[MAX_MESSAGE_COUNT]{};

	Message* idleQueue[MAX_MESSAGE_COUNT + 1]{};
	Message* busyQueue[MAX_MESSAGE_COUNT + 1]{};

	int32_t idleCount{};
	int32_t busyCount{};

	std::condition_variable signalIdle;
	std::condition_variable signalUsing;
	std::mutex guardIdle;
	std::mutex guardUsing;
};

